﻿jQuery(function($){
	var art_id =$('#artID').val();
	var noPart_id =art_id.replace('<p>','').replace('</p>','');
	$('#artID').val(noPart_id);
	var isUC = navigator.userAgent.toLowerCase().indexOf('uc');
	var isQQ = navigator.userAgent.toLowerCase().indexOf('qqbrowser');
	try{
		if (isUC>0)
		{
			$('#plbs')[0].value="UC浏览器用户";
		}
		else
		{
			$('#plbs')[0].value="中新手机网友";
		}
		if (isQQ>0)
		{
			$('#plbs')[0].value="QQ浏览器极速评论";
		}
		else
		{
			$('#plbs')[0].value="中新手机网友";
		}
	}
	catch(e){}
 //添加编辑处理事件
	var el = $('#content .docauthor');
	var str = el.text();
	el.html((str+'')=='【编辑：】' ? '':str);
 //验证码点击更新
  var validUrl =$('#myform .ref img').attr('src');
  $('#myform .ref a').bind('click', function(){
    $('#myform .ref img').attr('src', validUrl+'?'+(new Date().getTime()));
    return false;
  });
  //评论提交动作
  $('#pubComment').bind('click', function(){

    	sComment();

  });

  function sComment(){
    var message = $('#commentDesc').val();
    //alert('评论内容:'+message);
    if(!message)
    {
      alert('请填写评论内容');
      $('#commentDesc').focus();
      return false;
    }
    if(message.length > 300)
    {
      alert('评论内容字数太多');
      $('#commentDesc').focus();
      return false;
    }
    var validatecode = $('#validCode').val();
    if(!validatecode || validatecode.length!=2)
    {
      alert('请正确填写验证码');
      $('#validCode').focus();
      return false;
    }
    $.post("../../../../../../comment.chinanews.com/ci/index.php/wap/post_wapcmt/post",$('#myform form').first().serialize()); 

    if($.cookie('userInfo'))
    {
      $("input[name='username']").val($.cookie('userInfo').userName);
    }
    setTimeout(function(){
	alert('已提交完成，请稍后浏览！');
      	$('#commentDesc').val('');
 	$('#validCode').val('');
    }, 500);
    return true;
  }
});
